package com.michale.admin.controller.tool;

import com.michale.common.result.AjaxResult;
import com.michale.system.service.UploadService;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author Michale
 * @apiNote 文件上传管理
 */
@Api(tags = "文件上传管理")
@Controller
@RequestMapping("/tool/upload")
public class UploadController extends BaseController {

    @Resource
    private UploadService uploadService;

    @PostMapping("/images")
    public AjaxResult upload(@RequestPart("headerImg") MultipartFile headerImg, @RequestPart("photos") MultipartFile[] photos) throws IOException {
        return toAjax(uploadService.upLoadImages(headerImg, photos));
    }
}
